#
# sample.rex
# lexical scanner definition for rex
#

class RNGSample
macro
  COMMENT	;.*$
  BLANK         \s+
  NUM		\d+
  STRING	c?\"[^"]+\"
  BY		x
  TYPE		(i\d+\*?|label)
  OPERATOR      [a-zA-Z_]+
  ALIGN		align\s+\d+
  LOCAL		%[a-zA-Z0-9]+
  GLOBAL	\@[a-zA-Z0-9\.]+

rule
  {BLANK}
  {COMMENT}	{} # { puts "\tcomment:\t" + text }
  {NUM}		{ [:NUM,      text] }
  {STRING}	{ [:STRING,   text] }
  {BY}          { [:BY,       text] }
  {TYPE}        { [:TYPE,     text] }
  {ALIGN}	{ [:ALIGN,    text] }
  {OPERATOR}    { [:OPERATOR, text] }
  {IDENT}       { [:IDENT,    text] }
  {LOCAL}	{ [:LOCAL,    text] }
  {GLOBAL}	{ [:GLOBAL,   text] }
  .|\n          { [text, text] }

inner
end
